// #ifdef H5
import { createApp, h } from "vue";
import globalToast from "./global-toast.vue";
// #endif


let defaultOptions = {
  title: " ",
  icon: "none",
  mask: false,
  duration: 3000,
  position: "center"
}

/**
 * 重载 uni.showToast 
 * @returns {undefined}
 * @example globalToast.overloadingShowToast();
 * @author fmy
 * @see http://www.fmy.site
 */
export function overloadingShowToast(initOpt) {
  uni.__showToast = uni.showToast;
  if (initOpt) defaultOptions = Object.assign(defaultOptions, initOpt);

  // 重写 uni.showToast 
  Object.defineProperty(uni, "showToast", {
    value: (options) => {
      defaultOptions = Object.assign(defaultOptions, options);
      return uni.$emit("showToast", defaultOptions);
    }
  });
}

